﻿using Coldairarrow.Business.PB;
using Coldairarrow.Entity.PB;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.PB
{
    [Route("/PB/[controller]/[action]")]
    public class PB_UnloadBillController : BaseApiController
    {
        #region DI

        public PB_UnloadBillController(IPB_UnloadBillBusiness pB_UnloadBillBus)
        {
            _pB_UnloadBillBus = pB_UnloadBillBus;
        }

        IPB_UnloadBillBusiness _pB_UnloadBillBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<PB_UnloadBill>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _pB_UnloadBillBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<PB_UnloadBill> GetTheData(IdInputDTO input)
        {
            return await _pB_UnloadBillBus.GetTheDataAsync(input.id);
        }

        /// <summary>
        /// 卸车获取车辆
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<PB_UnloadBillPlateNO>> GetPB_UnloadBillPlateNO() {
            var list = await _pB_UnloadBillBus.Get_UnloadBillPlateNO();
            return list;
        }
        /// <summary>
        /// 根据派车单获取卸车明细
        /// </summary>
        /// <param name="Bild"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<List<PB_UnloadingDetails>> GetUnloadingDetails(string Bild){
            var list =await _pB_UnloadBillBus.Get_UnloadingDetails(Bild);
            return list;
}
        /// <summary>
        /// 保存卸车单
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task PB_UnloadBillInfoAdd(PB_UnloadBillInfo data) {
            await _pB_UnloadBillBus.PB_UnloadBillInfoAdd(data);
        }
        [HttpPost]
         public async Task<PB_UnloadBillMain> pB_UnloadBillMain(string UnloadId) {
           return await _pB_UnloadBillBus.pB_UnloadBillMain(UnloadId);
        }
        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(PB_UnloadBill data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _pB_UnloadBillBus.AddDataAsync(data);
            }
            else
            {
                await _pB_UnloadBillBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _pB_UnloadBillBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}